package com.example.esc_im_client.common.base;

/**
 * @Author: Etan96
 * @CreateDate: 2022/8/25 20:44
 * @Description: http状态码
 */
public enum HttpStatusCodeEM {

    RESP_SUCCEED(10200, "成功"),
    RESP_FAILED(10500, "失败"),
    PASSWORD_ERROR(10402, "账号或密码错误"),
    TOKEN_ERROR(10415, "Token验证失败"),
    SHORT_CODE_ERROR(10404, "验证码无效"),
    PHONE_ERROR(10406, "手机号无效"),
    MESSAGE_NOTHING(10407, "无内容"),
    MESSAGE_ERROR(10408, "输入内容有误"),
    MESSAGE_REPEAT(10409, "输入信息重复"),
    NULL_POINTER(10410, "空指针"),
    USER_IS_LOGIN(10411, "用户已注册"),

    //机器人相关，6开头
    NON_ROBOT_CONFIG(10601,"未查询到配置信息"),
    NON_FREE_CHATROOM(10602,"已经没有空闲的群"),


    //通用状态码
    INVALID_PARAMETER(10900,"参数不合法"),
    ROBOT_UNSUPPORTED(10901, "当前机器人类型不支持该项设置"),

    UNKNOWN(10999, "未知异常");

    private final Integer code;
    private final String msg;

    HttpStatusCodeEM(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }


    public Integer getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    /*
     * 匹配状态码
     * */
    public static HttpStatusCodeEM matchType(Integer code) {
        for (HttpStatusCodeEM httpStatusCodeEM : HttpStatusCodeEM.values()) {
            if (httpStatusCodeEM.getCode().equals(code)) {
                return httpStatusCodeEM;
            }
        }
        return HttpStatusCodeEM.UNKNOWN;
    }
}
